home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
001-025
/
scopedisk3
/
display
/
melt.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-18
|
4KB
|
162 lines
/***********************************************************************\
* *
* Melt -- Yet another screen hack. This is the direct *
* result of playing with Tilt too late at night. *
* Thank you Leo. *
* *
* Stephen Coy *
* 15407 Garden St. Apt. C *
* Sumner, WA 98390 *
* uw-beaver!ssc-vax!coy *
* *
* This program may be freely distributed, modified and *
* criticized. Use it as you see fit. *
* *
* Note: This compiles with Manx using 32-bit ints. If *
* you want 16-bit ints you should just have to *
* clean up melt(). *
* *
\***********************************************************************/
#include <exec/types.h>
#include <intuition/intuition.h>
#define DEPTH 2
extern void *OpenLibrary(), *OpenWindow(), *OpenScreen(), *GetMsg();
struct NewScreen scrdef = {
0, 0, 0, 0, DEPTH,
0, 1,
NULL,
CUSTOMSCREEN,
NULL,
(UBYTE *) "Help me!",
NULL, NULL
};
struct NewWindow windef = {
0, 30, 140, 10,
-1, -1,
CLOSEWINDOW,
WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH |
SMART_REFRESH | ACTIVATE,
NULL, NULL,
(UBYTE *) "Melt",
NULL, NULL,
0, 0, 0, 0,
WBENCHSCREEN
};
struct Screen *scr;
struct Window *win;
struct TmpRas tmpras;
void *IntuitionBase, *GfxBase;
main()
{
struct Screen *wb;
struct RastPort *rp;
struct BitMap *wbm, *mbm;
long x, y, n;
register int i;
openstuff();
wb = win->WScreen;
scrdef.LeftEdge = wb->LeftEdge;
scrdef.TopEdge = wb->TopEdge;
scrdef.Width = wb->Width;
scrdef.Height = wb->Height;
scrdef.ViewModes = wb->ViewPort.Modes;
if(!(scr = OpenScreen(&scrdef)))
die("Screen open failed!");
ScreenToBack(scr);
rp = &scr->RastPort;
mbm = rp->BitMap;
wbm = win->WScreen->RastPort.BitMap;
BltBitMap(wbm, 0L, 0L, mbm, 0L, 0L,
(long)scrdef.Width, (long)scrdef.Height,
0xc0L, 0xffL, NULL);
ScreenToFront(scr);
melt(rp, mbm);
closestuff();
}
melt(rp, bitmap)
struct RastPort *rp;
struct BitMap *bitmap;
{
int class;
struct IntuiMessage *message;
int x, y, /* start positions */
dx, dy, /* offsets */
u, v; /* size */
int TempA[32]; /* temp buffer */
char mask; /* bit-plane mask for blitter */
FOREVER {
message = (struct IntuiMessage *)GetMsg(win->UserPort);
if(message != (struct IntuiMessage *)NULL) {
class = message->Class;
ReplyMsg(message);
if(class == CLOSEWINDOW) {
return;
}
}
for(mask=1; mask<+(1<<DEPTH)-1; mask*=2) {
u = RangeRand(scr->Width - 3) + 1;
v = RangeRand(scr->Height - 3) + 1;
x = RangeRand(scr->Width - 1 - u) + 1;
y = RangeRand(scr->Height - 2 - v) + 1;
dx = RangeRand(3) - 1;
dy = RangeRand(3); /* also try dy = RangeRand(3) - 1; */
BltBitMap(bitmap, (long)x, (long)y,
bitmap, (long)(x+dx), (long)y+dy,
(long) u, (long) v, (long)0x0c0, (long)mask, TempA);
} /* end of for mask */
} /* end of FOREVER */
} /* end of melt */
openstuff()
{
if(!(IntuitionBase = OpenLibrary("intuition.library", 0L))) {
puts("Intuition missing.");
exit(100);
}
if(!(GfxBase = OpenLibrary("graphics.library", 0L))) {
puts("Art shop clode.");
exit(100);
}
if(!(win = OpenWindow(&windef))) {
puts("Window painted shut.");
closestuff();
exit(100);
}
}
die(str)
char *str;
{
puts(str);
closestuff();
exit(100);
}
closestuff()
{
if(tmpras.RasPtr) FreeRaster(tmpras.RasPtr, 320, 200);
if(scr) CloseScreen(scr);
if(win) CloseWindow(win);
if(GfxBase) CloseLibrary(GfxBase);
if(IntuitionBase) CloseLibrary(IntuitionBase);
}